home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / ODBCINF.PAK / CATSETS.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  109 lines

  1. // catsets.cpp
  2.  
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1996 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "catsets.h"
  15.  
  16. //---------------------------------------------------------------------
  17. // CGetTypeInfo
  18.  
  19. CGetTypeInfo::CGetTypeInfo(CDatabase* pDatabase)
  20.     : CRecordset(pDatabase)
  21. {
  22.     m_strTypeName            = _T("");
  23.     m_fDataType                = 0;
  24.     m_nPrecision            = 0;
  25.     m_strLiteralPrefix        = _T("");
  26.     m_strLiteralSuffix        = _T("");
  27.     m_strCreateParams        = _T("");
  28.     m_fNullable                = 0;
  29.     m_bCaseSensitive        = 0;
  30.     m_fSearchable            = 0;
  31.     m_fUnsignedAttribute    = 0;
  32.     m_bMoney                = 0;
  33.     m_fAutoIncrement        = 0;
  34.     m_strLocalTypeName        = _T("");
  35.     m_nMinimumScale            = 0;
  36.     m_nMaximumScale            = 0;
  37.     m_nFields = 15;
  38. }
  39.  
  40. BOOL CGetTypeInfo::Open(short fSqlType,
  41.     UINT nOpenType)
  42. {
  43.     RETCODE    nRetCode;
  44.     UWORD    bFunctionExists;
  45.  
  46.     // make suer SQLGetTypeInfo exists
  47.     AFX_SQL_SYNC(::SQLGetFunctions(m_pDatabase->m_hdbc,
  48.         SQL_API_SQLGETTYPEINFO,&bFunctionExists));
  49.     if (!Check(nRetCode) || !bFunctionExists)
  50.     {
  51.         if (!bFunctionExists)
  52.             TRACE(_T("SQLGetTypeInfo not supported\n"));
  53.         return FALSE;
  54.     }
  55.  
  56.     m_nOpenType = nOpenType;
  57.     m_bUpdatable = FALSE;
  58.  
  59.     // make sure hstmt is allocated
  60.     if (m_hstmt == SQL_NULL_HSTMT)
  61.     {
  62.         AFX_SQL_SYNC(::SQLAllocStmt(m_pDatabase->m_hdbc,&m_hstmt));
  63.         if (!Check(nRetCode))
  64.             ThrowDBException(nRetCode,m_hstmt);
  65.     }
  66.  
  67.     OnSetOptions(m_hstmt);
  68.  
  69.     // call the ODBC function
  70.     AFX_SQL_ASYNC(this,::SQLGetTypeInfo(m_hstmt,fSqlType));
  71.  
  72.      if (!Check(nRetCode))
  73.         ThrowDBException(nRetCode,m_hstmt);
  74.  
  75.     TRY
  76.     {
  77.         MoveFirst();
  78.     }
  79.  
  80.     CATCH_ALL(e)
  81.     {
  82.         Close();
  83.         THROW_LAST();
  84.     }
  85.     END_CATCH_ALL
  86.  
  87.     return TRUE;
  88. }
  89.  
  90. void CGetTypeInfo::DoFieldExchange(CFieldExchange* pFX)
  91. {
  92.     pFX->SetFieldType(CFieldExchange::outputColumn);
  93.     RFX_Text(pFX,_T("TYPE_NAME"),m_strTypeName);
  94.     RFX_Int(pFX,_T("DATA_TYPE"),m_fDataType);
  95.     RFX_Long(pFX,_T("PRECISION"),m_nPrecision);
  96.     RFX_Text(pFX,_T("LITERAL_PREFIX"),m_strLiteralPrefix);
  97.     RFX_Text(pFX,_T("LITERAL_SUFFIX"),m_strLiteralSuffix);
  98.     RFX_Text(pFX,_T("CREATE_PARAMS"),m_strCreateParams);
  99.     RFX_Int(pFX,_T("NULLABLE"),m_fNullable);
  100.     RFX_Bool(pFX,_T("CASE_SENSITIVE"),m_bCaseSensitive);
  101.     RFX_Int(pFX,_T("SEARCHABLE"),m_fSearchable);
  102.     RFX_Int(pFX,_T("UNSIGNED_ATTRIBUTE"),m_fUnsignedAttribute);
  103.     RFX_Bool(pFX,_T("MONEY"),m_bMoney);
  104.     RFX_Int(pFX,_T("AUTO_INCREMENT"),m_fAutoIncrement);
  105.     RFX_Text(pFX,_T("LOCAL_TYPE_NAME"),m_strLocalTypeName);
  106.     RFX_Int(pFX,_T("MINIMUM_SCALE"),m_nMinimumScale);
  107.     RFX_Int(pFX,_T("MAXIMUM_SCALE"),m_nMaximumScale);
  108. }
  109.